package com.newcapec.news.servlet;

import com.newcapec.news.entity.Channel;
import com.newcapec.news.entity.News;
import com.newcapec.news.service.ChannelService;
import com.newcapec.news.service.NewService;
import com.newcapec.news.service.impl.ChannelServiceImpl;
import com.newcapec.news.service.impl.NewServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Description: 登录页面的展示
 * @Author: fujun
 * @Date : 2022/3/16 16:08
 * @Version : 1.0
 * @company 新开普电子股份有限公司
 */
@WebServlet("/html/news_content.html")
public class ShowNewsContextHtmlServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //根据id查询指定的新闻

        String sid=req.getParameter("id");

        NewService newService=new NewServiceImpl();

        News news = newService.getNews(Integer.parseInt(sid));


        req.setAttribute("news",news);
        req.getRequestDispatcher("news_content.jsp").forward(req,resp);




    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
